<?php

/**
 * @author Samrat Khan & Sadik Sarfaraz - May 19, 2013
 */
require 'top.inc.php';
$formLoad = new Form();
if(isset($_SESSION['user']) && $_SESSION['user']['utype'] == 1 || $_SESSION['user']['utype'] == 2 || $_SESSION['user']['utype'] == 3 || $_SESSION['user']['utype'] == 4) {
    $sess_cusID = $_SESSION['user']['cus_id'];
?>
<form name="addReturn" id="addReturn" method="post">
<?php
echo "<table class=\"form-inline row-fluid table table-striped table-bordered\">";
    echo "<tr>";
        echo "<th>" . $return['serialno'] . "</th>";
        echo "<th>" . $return['project_id'] . "</th>";
        echo "<th>" . $return['return_rma'] . "</th>";
        echo "<th>" . $return['pickuprequestdate'] . "</th>";
        echo "<th>" . $return['physicallyreceivedate'] . "</th>";
        echo "<th>" . $return['productid'] . "</th>";
        echo "<th>" . $return['description'] . "</th>";
        echo "<th>" . $return['revisionstate'] . "</th>";
        echo "<th>" . $return['boxno'] . "</th>";
        echo "<th>" . $return['uom'] . "</th>";
        echo "<th>" . $return['return_quantity'] . "</th>";
        echo "<th>" . $return['manufacturingdate'] . "</th>";
        echo "<th>" . $return['returningstatus'] . "</th>";
        echo "<th>" . $return['receivedfrom'] . "</th>";
        echo "<th>" . $return['siteid'] . "</th>";
        echo "<th>" . $return['warehouse_id'] . "</th>";
        echo "<th>" . $return['employee_id'] . "</th>";
        echo "<th>" . $return['docketdate'] . "</th>";
        echo "<th>" . $return['return_docketnumber'] . "</th>";
        echo "<th>" . $return['remarks'] . "</th>";
        echo "<th>" . "&nbsp;" . "</th>";
    echo "</tr>";
    
    echo "<tr>";
        echo "<td>" . $formLoad->textField("serialno", "", "faulty_in_sn", $stock_in['serialno']) . "</td>";
        echo "<td>";
            echo "<select name='project_id'>";
                echo getProjects(cus_id, $sess_cusID, $db);
            echo "</select>";
        echo "</td>";
        echo "<td>" . $formLoad->textField("return_rma", "", "", $return['return_rma']) . "</td>";
        echo "<td>" . $formLoad->textField("pickuprequestdate", "", "pickuprequestdate", $return['pickuprequestdate']) . "</td>";
        echo "<td>" . $formLoad->textField("physicallyreceivedate", "", "physicallyreceivedate", $return['physicallyreceivedate']) . "</td>";
        echo "<td>" . $formLoad->textField("productid", "", "", $return['productid']) . "</td>";
        echo "<td>" . $formLoad->textArea("description", "", "") . "</td>";
        echo "<td>" . $formLoad->textField("revisionstate", "", "", $return['revisionstate']) . "</td>";
        echo "<td>" . $formLoad->textField("boxno", "", "", $return['boxno']) . "</td>";
        echo "<td>";
            echo "<select name='uom'>";
                echo getUOM($db);
            echo "</select>";
        echo "</td>";
        echo "<td>" . $formLoad->textField("return_quantity", "", "", $return['return_quantity']) . "</td>";
        echo "<td>" . $formLoad->textField("manufacturingdate", "", "manufacturingdate", $return['manufacturingdate']) . "</td>";
        echo "<td>";
            echo "<select name='returningstatus'>";
                echo getReturningStatus($db);
            echo "</select>";
        echo "</td>";
        echo "<td>" . $formLoad->textField("receivedfrom", "", "", $return['receivedfrom']) . "</td>";
        echo "<td>" . $formLoad->textField("siteid", "", "", $return['siteid']) . "</td>";
        echo "<td>";
            echo "<select name='warehouse_id'>";
                echo getWarehousesCode($db);
            echo "</select>";
        echo "</td>";
        echo "<td>";
            echo "<select name='employee_id'>";
                echo getEmployees($db);
            echo "</select>";
        echo "</td>";
        echo "<td>" . $formLoad->textField("docketdate", "", "docketdate", $return['docketdate']) . "</td>";
        echo "<td>" . $formLoad->textField("return_docketnumber", "", "", $return['return_docketnumber']) . "</td>";
        echo "<td>" . $formLoad->textArea("remarks", "", "") . "</td>";
        
        echo '<input type="hidden" name="userid" value="'.$_SESSION['user']['id'].'" />';
        echo '<input type="hidden" name="cus_id" value="'.$_SESSION['user']['cus_id'].'" />';
        echo '<input type="hidden" name="session_id" value="'.  session_id() .'" />';
        echo '<input type="hidden" name="junkentry" value="0" />';
        echo "<td>";
            echo '<input id="AddReturnBtn" class="btn btn-primary" type="submit" value="Add Return" name="addReturn" />';
        echo "</td>";
    echo "</tr>";
echo "<table>";
?>
</form>

<div id="show"></div>
<?php
}
include 'bottom.inc.php';
?>
